<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Auth::routes();

// Route::get('/home', 'HomeController@index')->name('home');

Route::any('/redis', 'TestController@redis');
Route::any('/test', 'TestController@index');


//微信消息接口
Route::any('/wechat', 'WeChatController@serve');//测试号
Route::any('/wechat_yiranzai', 'WeChatController@serve_yiranzai');//公众号

Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');

//上传接口
Route::group(['middleware' => 'web', 'namespace' => 'Upload', 'prefix' => 'upload'], function () {
    Route::get('/', 'UploadController@index')->name('index');
    Route::get('/index', 'UploadController@index')->name('index');
    Route::post('/upload', 'UploadController@upload')->name('upload');
    Route::get('/qc_init', 'UploadController@qc_init')->name('qc_init');
});


//API管理
Route::group(['middleware' => 'web', 'namespace' => 'Api', 'prefix' => 'api'], function () {

    Route::post('/get_children_classify', 'ClassifyController@get_children_classify')->name('get_children_classify');

    Route::post('/get_commodity_by_classify', 'CommodityController@get_commodity_by_classify')->name('get_commodity_by_classify');

    Route::post('/get_citys', 'AddressController@get_citys')->name('get_citys');
    Route::post('/get_county', 'AddressController@get_county')->name('get_county');
    Route::post('/get_provinces', 'AddressController@get_provinces')->name('get_provinces');

    Route::post('/add_user_address', 'UserAddressController@add_user_address')->name('add_user_address');
    Route::post('/update_user_address', 'UserAddressController@update_user_address')->name('update_user_address');
    Route::post('/get_user_address', 'UserAddressController@get_user_address')->name('get_user_address');
    Route::post('/delete_user_address', 'UserAddressController@delete_user_address')->name('delete_user_address');

    Route::post("/add_cart", "CartController@add_cart")->name("add_cart");
    Route::post("/delete_cart", "CartController@delete_cart")->name("delete_cart");
    Route::post("/up_cart_num", "CartController@up_cart_num")->name("up_cart_num");
    Route::post("/set_cart_session", "CartController@set_cart_session")->name("set_cart_session");
    Route::post("/reduce_cart_num", "CartController@reduce_cart_num")->name("reduce_cart_num");

    Route::post("/recharge", "UserController@recharge")->name("recharge");

    Route::post("/add_order", "OrderController@add_order")->name("add_order");
    Route::post("/pay_order", "OrderController@pay_order")->name("pay_order");
    Route::post("/cancel_order", "OrderController@cancel_order")->name("cancel_order");
    Route::post("/add_state", "OrderController@add_state")->name("add_state");
    Route::post("/delete_order", "OrderController@delete_order")->name("delete_order");
    Route::post("/close_order", "OrderController@close_order")->name("close_order");

});


//微信授权
Route::group(['middleware' => ['web', 'wechat.oauth:default,snsapi_userinfo', 'checkUser']], function () {


    Route::get('/search', 'Commodity\CommodityController@search');

    Route::group(['middleware' => 'web', 'namespace' => 'Commodity', 'prefix' => 'commodity'], function () {
        Route::get('/{commodity}', 'CommodityController@commodity')->name('commodity');
        Route::get('/search/{name}', 'CommodityController@res')->name('res');
        Route::get('/list/parent/{parent}/classify/{classify}', 'CommodityController@list')->name('list');
    });


    Route::group(['middleware' => 'web', 'namespace' => 'Home', 'prefix' => 'home'], function () {
        Route::get('/', 'HomeController@index')->name('index');
        Route::get('/index', 'HomeController@index')->name('index');
        Route::get('/license', 'HomeController@license')->name('license');
    });

    Route::group(['middleware' => 'web', 'namespace' => 'Cart', 'prefix' => 'cart'], function () {
        Route::get('/edit', 'CartController@edit')->name('edit');
        Route::get('/', 'CartController@index')->name('index');
        Route::get('/index', 'CartController@index')->name('index');
        Route::get('/right', 'CartController@right')->name('right');

    });

    Route::group(['middleware' => 'web', 'namespace' => 'User', 'prefix' => 'user'], function () {
        Route::get('/', 'UserController@index')->name('index');
        Route::get('/index', 'UserController@index')->name('index');
        Route::get('/balance', 'UserController@balance')->name('balance');

        Route::get('/address/list', 'AddressController@list')->name('list');
        Route::get('/address/add', 'AddressController@add')->name('add');

        Route::get('/order/list', 'OrderController@list')->name('list');
        Route::get('/order/zero', 'OrderController@zero')->name('zero');
        Route::get('/order/one', 'OrderController@one')->name('one');
        Route::get('/order/two', 'OrderController@two')->name('two');
        Route::get('/order/three', 'OrderController@three')->name('three');
        Route::get('/order/{orderId}', 'OrderController@index')->name('index');
    });

    Route::group(['middleware' => 'web', 'namespace' => 'Classify', 'prefix' => 'classify'], function () {
        Route::get('/', 'ClassifyController@index')->name('index');
        Route::get('/{classify}', 'ClassifyController@classify')->name('classify');
//        Route::get('/index', 'ClassifyController@index')->name('index');
    });

    Route::group(['middleware' => 'web', 'namespace' => 'Order', 'prefix' => 'order'], function () {
        Route::get('/', 'OrderController@index')->name('index');
        Route::get('/pay/{payId}', 'OrderController@pay')->name('pay');
//        Route::get('/index', 'ClassifyController@index')->name('index');
    });


    Route::get('/', 'IndexController@index');
    Route::get('/index', 'IndexController@index');


    // Route::get('/make_menu',function(){
    //     $app = EasyWeChat::officialAccount("default");
    //     $buttons = [
    //         [
    //             "type" => "view",
    //             "name" => "我的博客",
    //             "url" => "http://shop.yiranzai.cn/"
    //         ],
    //         [
    //             "name" => "菜单",
    //             "sub_button" => [
    //                 [
    //                     "type" => "view",
    //                     "name" => "博客",
    //                     "url" => "http://blog.yiranzai.cn/"
    //                 ],
    //                 [
    //                     "type" => "click",
    //                     "name" => "赞一下我们",
    //                     "key" => "V1001_GOOD"
    //                 ],
    //             ],
    //         ],
    //     ];
    //     $app->menu->create($buttons);
    // });

});

